package com.ss.android.article.browser.setting;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.widget.EditText;
import com.bytedance.common.utility.UIUtils;
import com.bytedance.ttnet.a.AppConfig;
import com.ss.android.article.base.app.AppData;
import com.ss.android.article.browser.R;
import com.ss.android.common.ui.view.SwitchButton;
import com.ss.android.common.util.ToolUtils;
import com.ss.android.newmedia.activity.FragmentActivity;
import java.util.regex.Pattern;

public class ProjectModeActivity extends FragmentActivity {
    private AppData a;
    private EditText b;

    public ProjectModeActivity() {

    }

    static void a(ProjectModeActivity arg3) {
        int v2 = R.drawable.doneicon_popup_textpage;
        if(arg3.b != null) {
            String v0 = arg3.b.getEditableText().toString().trim();
            if(Pattern.compile("^\\s*(.*?):(\\d+)\\s*$").matcher(((CharSequence)v0)).matches()) {
                arg3.a.d(v0);
                UIUtils.showImageToast(((Context)arg3), v2, R.string.jx);
            }
            else if(TextUtils.isEmpty(((CharSequence)v0))) {
                arg3.a.d("");
                UIUtils.showImageToast(((Context)arg3), v2, R.string.ju);
            }
            else {
                UIUtils.showImageToast(((Context)arg3), R.drawable.close_popup_textpage, R.string.jv);
            }
        }
    }

    public int getLayout() {
        return R.layout.a7;
    }

    public void init() {
        super.init();
        this.setTitle(this.getResources().getString(com.ss.android.article.browser.R.string.sp));
        this.a = a.getInstance();
        this.b = (EditText) this.findViewById(com.ss.android.article.browser.R.id.i0);
        this.b.setText(this.a.getEventSenderHost());
        this.b.setOnEditorActionListener(new c(this));
        this.findViewById(com.ss.android.article.browser.R.id.i1).setOnClickListener(new d(this));
        View v0 = this.findViewById(com.ss.android.article.browser.R.id.i4);
        boolean v1 = !AppConfig.getInstance(this.getApplicationContext()).n() ? true : false;
        ((SwitchButton)v0).setChecked(v1);
        ((SwitchButton)v0).setOnCheckStateChangeListener(new b(this));
    }

    public void onBackPressed() {
        super.onBackPressed();
        if(!this.isFinishing()) {
            Intent v0 = null;
            if(this.isTaskRoot()) {
                v0 = ToolUtils.getLaunchIntentForPackage(((Context)this), this.getPackageName());
            }

            this.finish();
            if(v0 == null) {
                return;
            }

            this.startActivity(v0);
        }
    }
}

